<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			// 1.打印每一位数字
			document.write("1、打印每一位数字<br/>")
			function getNum(num) {
				while(num!=0) {
					document.write(num%10+" ");
					num = Math.floor(num/10);
				}
			}
			getNum(1234);
			document.write("<br/><br/>")
			// 2.求水仙花数
			document.write("2、求水仙花数<br/>")
			for(var i = 1; i <= 9; i ++) {
				for(var j = 0; j <= 9; j ++) {
					for(var k = 0; k <= 9; k ++) {
						if((i*i*i + j*j*j + k*k*k) == (i*100 + j*10 +k)) {
							document.write((i*100 + j*10 +k)+" ");
						}
					}
				}
			}
			document.write("<br/><br/>");
			
			// 3.数字反转
			document.write("3、数字反转<br/>")
			function reverseNum(num) {
				while(num!=0) {
					document.write(num%10);
					num = Math.floor(num/10);
				}
			}
			reverseNum(1234);
			document.write("<br/><br/>");
			
			// 4.百钱白鸡
			document.write("4、百钱白鸡<br/>")
			for(var i = 1; i < 20; i ++) {
				for(var j = 1; j < 33; j ++) {
					if(i*5 + j*3 + (100-i-j)*(1/3) == 100) {
						document.write("公鸡:"+i+" 母鸡:"+j+" 小鸡:"+(100-i-j)+"<br/>");
					}
				}
			}
			document.write("<br/>");
			// 5.求n的阶乘
			document.write("5、求n的阶乘<br/>")
			function getFactorial(num) {
				if (num>=1) {
					return num*getFactorial(num-1);
				} else {
					return 1;
				}
			}
			var result = getFactorial(5);
			document.write(result);
			document.write("<br/>");
		</script>
	</head>
	<body>
	</body>
</html>
